﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Perfiles.aspx.cs" Inherits="Proyectos_Perfiles_Perfiles" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register Src="wucPerfiles.ascx" TagName="wucPerfiles" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../resources/css/rownumber.css" />
</head>
<body>
    <form id="form1" runat="server">
    <ext:ScriptManager ID="smPerfiles" runat="server"  Theme="Gray"/>

    <script type="text/javascript" language="javascript" src="../../resources/utilidades.js"></script>

    <ext:Store ID="StoreProgramas" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreEje" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreProyectos" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Id">
                <Fields>
                    <ext:RecordField Name="Id" />
                    <ext:RecordField Name="Nombre" />
                    <ext:RecordField Name="Descripcion" />
                    <ext:RecordField Name="Tipo" />
                    <ext:RecordField Name="Estado" />
                    <ext:RecordField Name="Latitud" />
                    <ext:RecordField Name="Longitud" />
                    <ext:RecordField Name="Dictamen" />
                    <ext:RecordField Name="Viabilidad" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreEstado" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="sTipo" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>

    <script type="text/javascript" language="javascript">
        
        var columnaRenderer = function(value) {
                var r = <%= this.StoreEstado.ClientID %>.getById(value);

                if (Ext.isEmpty(r)) {
                    return value;
                }

                return r.data['Value'];
            };
            var columnaRendererTipo = function(value) {
                var r = <%= this.sTipo.ClientID %>.getById(value);

                if (Ext.isEmpty(r)) {
                    return value;
                }

                return r.data['Value'];
            };
    </script>

    <ext:Panel Border="false" BodyStyle="padding:10px;background-color:Transparent;"
        runat="server" AutoHeight="true" ButtonAlign="Center">
        <Body>
            <ext:Panel runat="server" BodyStyle="background-color:Transparent;">
                <Body>
                    <ext:ColumnLayout runat="server">
                        <ext:LayoutColumn ColumnWidth=".5">
                            <ext:Panel runat="server" Border="false" Header="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Body>
                                    <ext:FormLayout ID="FormLayout1" runat="server" LabelAlign="Left" LabelWidth="70">
                                        <ext:Anchor Horizontal="95%">
                                            <ext:ComboBox Editable="false" FieldLabel="Eje" ID="cbxEje" StoreID="StoreEje" runat="server"
                                                DisplayField="Value" ValueField="Key" TypeAhead="true" ForceSelection="true"
                                                TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos" SelectOnFocus="true"
                                                AutoDataBind="True">
                                                <Triggers>
                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                </Triggers>
                                                <Listeners>
                                                    <Select Handler="this.triggers[0].show();" />
                                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                                </Listeners>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                </Body>
                            </ext:Panel>
                        </ext:LayoutColumn>
                        <ext:LayoutColumn ColumnWidth=".5">
                            <ext:Panel runat="server" Border="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Body>
                                    <ext:FormLayout ID="FormLayout2" LabelSeparator=":" runat="server" LabelAlign="Left"
                                        LabelWidth="65">
                                        <ext:Anchor Horizontal="95%">
                                            <ext:ComboBox Editable="false" FieldLabel="Programa" ID="cbxProgramas" runat="server"
                                                StoreID="StoreProgramas" DisplayField="Value" ValueField="Key" TypeAhead="true"
                                                ForceSelection="true" TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos"
                                                SelectOnFocus="true" AutoDataBind="True">
                                                <Triggers>
                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                </Triggers>
                                                <Listeners>
                                                    <Select Handler="this.triggers[0].show();" />
                                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                                </Listeners>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                </Body>
                            </ext:Panel>
                        </ext:LayoutColumn>
                    </ext:ColumnLayout>
                </Body>
            </ext:Panel>
        </Body>
        <Buttons>
            <ext:Button runat="server" ID="Button1" Text="Buscar" Icon="Find">
                <AjaxEvents>
                    <Click OnEvent="btnBuscar_Click">
                        <EventMask ShowMask="true" />
                    </Click>
                </AjaxEvents>
            </ext:Button>
        </Buttons>
    </ext:Panel>
    <ext:GridPanel runat="server" Border="false" ID="gpPerfilProyecto" StoreID="StoreProyectos"
        Height="380" AutoExpandColumn="DescripcionProyecto" EnableColumnHide="false"
        StripeRows="true" TrackMouseOver="true">
        <TopBar>
            <ext:Toolbar ID="tobPerfilProyecto" runat="server">
                <Items>
                    <ext:Button runat="server" ID="btnNuevo" Text="Nuevo Perfil de Proyecto" Icon="Add">
                        <AjaxEvents>
                            <Click OnEvent="btnNuevo_click">
                                <ExtraParams>
                                    <ext:Parameter Name="operacion" Value="Nuevo">
                                    </ext:Parameter>
                                </ExtraParams>
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <ColumnModel ID="clmBuscarPerfilProyecto" runat="server">
            <Columns>
                <ext:RowNumbererColumn Width="20">
                </ext:RowNumbererColumn>
                <ext:CommandColumn Width="50">
                    <Commands>
                        <ext:GridCommand ToolTip-Text="Editar Perfil de Proyecto" Icon="PageEdit" CommandName="Editar">
                        </ext:GridCommand>
                        <ext:GridCommand ToolTip-Text="Eliminar Perfil de Proyecto" Icon="PageDelete" CommandName="Eliminar">
                        </ext:GridCommand>
                    </Commands>
                </ext:CommandColumn>
                <ext:Column ColumnID="NombreProyecto" Header="Proyecto" Width="200" DataIndex="Nombre" />
                <ext:Column DataIndex="Tipo" Header="Tipo" Width="100">
                    <Renderer Fn="columnaRendererTipo" />
                </ext:Column>
                <ext:Column ColumnID="DescripcionProyecto" DataIndex="Descripcion" Header="Descripción"
                    Width="200" />
                <ext:Column DataIndex="Estado" Header="Estado" Width="100">
                    <Renderer Fn="columnaRenderer" />
                </ext:Column>
                <ext:Column DataIndex="Dictamen" Header="Dictamen" Width="100" />
                <ext:Column DataIndex="Viabilidad" Header="Viabilidad" Width="100" />
            </Columns>
        </ColumnModel>
        <LoadMask ShowMask="true" />
        <SaveMask ShowMask="true" />
        <AjaxEvents>
            <Command OnEvent="Editar_Click">
                <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{gpPerfilProyecto}.body}" />
                <ExtraParams>
                    <ext:Parameter Name="id" Value="record.data.Id" Mode="Raw" />
                    <ext:Parameter Name="operacion" Value="command" Mode="Raw" />
                </ExtraParams>
            </Command>
        </AjaxEvents>
        <SelectionModel>
            <ext:RowSelectionModel ID="rsmPerfilProyecto" runat="server" />
        </SelectionModel>
        <BottomBar>
            <ext:PagingToolbar ID="ptbPerfilProyecto" runat="server" StoreID="StoreProyectos"
                DisplayInfo="true" DisplayMsg="Perfiles de Proyectos {0} - {1} of {2}" EmptyMsg="No existen Perfiles de Proyectos" />
        </BottomBar>
    </ext:GridPanel>
    <uc1:wucPerfiles runat="server" ID="wucPerfiles1" />
    </form>
</body>
</html>
